'use strict';
import Base from './base.js';
export default class extends Base{

	// 获取店家信息
	async getshopinfo(){
		let data = await this.model('or_department').alias('d').field('d.*, os.phone, os.address').join('think_or_shopinfo os on os.s_id = d.id').where({'d.id':this.shop_userinfo.departmentid}).find();
		return data;
	}

	// 获取订单信息
	async getorderinfo(id){
		let oinfo = await this.model('or_shop_order')
								.alias('o')
								.field('o.*, g.name, g.vipcard, g.balance as yue, g.giftbalance as zsyue')
								.join('`think_or_guest` g on g.id=o.guestid')
								.where({'o.id':id})
								.find();
		return oinfo;
	}

	// 获取开卡订单列表信息
	async getorderlistinfoAction(){
			let id = this.post('id');
			let sinfo = await this.getshopinfo();
			// 获取订单信息
			let oinfo = await this.getorderinfo(id);
			// 获取订单分表数据
			let olist = await this.model('or_shop_orderinfo')
			.alias('o')
			.field('o.*, g.nownum, g.cardtype, g.endtime')
			.join('left join `think_or_shop_guestcardsubject` g on o.guestcardinfoid = g.id')
			.where({'o.orderid':id})
			.select();
			let data = {
				sinfo 	: sinfo,
				oinfo 	: oinfo,
				olist 	: olist,
			}

			return this.json(data);
	}



















}